package com.alan.builder.standard;

/**
 * Created by Alan on 2018/8/22.
 */
public class Reservation {
    private String name;
    private String type;

    //私有化构造器，不允许用户创建
    private Reservation(){}

    private Reservation(Builder builder){
        name = builder.getName();
        type = builder.getType();
    }

    @Override
    public String toString() {
        return "Reservation{" +
                "name='" + name + '\'' +
                ", type='" + type + '\'' +
                '}';
    }

    public static Builder newBuilder(){
        return new Reservation.Builder();
    }

    //内置构建器
    public static final class Builder {
        private String name;
        private String type;

        private Builder(){}

        public Reservation build(){
            return new Reservation(this);
        }

        public String getName() {
            return name;
        }

        public Builder setName(String name) {
            this.name = name;
            return this;
        }

        public String getType() {
            return type;
        }

        public Builder setType(String type) {
            this.type = type;
            return this;
        }

    }
}
